import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        redirect: '/home'
    },
    {
        path: '/home',
        name: 'Home',
        component: () => import('@/views/Home')
    },
    {
        path: '/person',
        redirect: '/person/user'
    },
    {
        path: '/person/user',
        name: 'PersonUser',
        component: () => import('@/views/person/user')
    },
    {
        path: '/person/worker',
        name: 'PersonWorker',
        component: () => import('@/views/person/worker')
    },
    {
        path: '/operate/ticketList',
        name: 'TicketList',
        component: () => import('@/views/operate/ticket')
    },
    {
        path: '/operate/ticketRecord',
        name: 'TicketRecord',
        component: () => import('@/views/operate/record')
    },
    {
        path: '/business/order',
        name: 'BusinessOrder',
        component: () => import('@/views/business/order')
    },
    {
        path: '/business/refund',
        name: 'BusinessRefund',
        component: () => import('@/views/business/refund')
    },
    {
        path: '/adver/adver',
        name: 'Adver',
        component: () => import('@/views/adver/adver')
    },
    {
        path: '/authority/user',
        name: 'Authority',
        component: () => import('@/views/authority/user')
    },
    {
        path: '/log/log',
        name: 'Log',
        component: () => import('@/views/log/log')
    },
    {
        path:'/goods/list',
        name:'GoodsList',
        component: () => import('@/views/goods/list')
    },
    {
        path:'/goods/type',
        name:'GoodsType',
        component: () => import('@/views/goods/type')
    },
    {
        path: '/params/vehicle',
        name: 'Vehicle',
        component: () => import('@/views/params/vehicle')
    },
    {
        path: '/project/list',
        name: 'Project',
        component: () => import('@/views/project/project')
    },
]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

// router.beforeEach((to, from, next) => {
//     if (to.path === "/" || to.path === "/home"){
//         next()
//     } else{
//         if (!sessionStorage.getItem("token")) {
//             window.location.replace("http://" + location.hostname + ":8110/view/login")
//         }else{
//             next()
//         }
//     }
// })

export default router
